namespace BM.Tools.WebControls.MForm.Navigation.NodeTests
{
    using System.Collections.Generic;

    using BM.Tools.WebControls.MForm.Navigation.XPath;

    /// <summary>
    /// A navigator for the <see cref="NodeTest" /> locator.
    /// </summary>
    /// <typeparam name="T">
    /// The type of the navigable object.
    /// </typeparam>
    /// <typeparam name="TLocator">
    /// the type of the node test
    /// </typeparam>
    public abstract class NodeTestNavigator<T, TLocator> : Navigator<T, TLocator> where TLocator : NodeTest
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="NodeTestNavigator{T, TLocator}"/> class. 
        /// </summary>
        /// <param name="parent">
        /// The parent.
        /// </param>
        /// <param name="locator">
        /// The locator.
        /// </param>
        protected NodeTestNavigator(INavigator<T> parent, TLocator locator) : base(parent, locator)
        {
        }

        /// <summary>
        /// Performs the selection of parent query
        /// </summary>
        /// <returns>
        /// the enumerable of current results
        /// </returns>
        protected IEnumerable<T> CurrentResults()
        {
            return Parent.Select();
        }        
    }
}